package com.atguigu.edu.publisher.mapper;

import com.atguigu.edu.publisher.beans.TradeSubjectOrderAmount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;


/**
 * 交易域统计Mapper接口
 */
@Mapper
public interface TradeStatsMapper {
    //获取某天总交易额
    @Select("SELECT sum(order_total_amount) order_total_amount\n" +
            "FROM `dws_trade_course_order_window`\n" +
            "PARTITION par#{date}")
    BigDecimal selectGMV(Integer date);

   //各科目下单总金额取前10名
    @Select("select course_name,\n" +
            "sum(order_total_amount) order_total_amount\n" +
            "from dws_trade_course_order_window\n" +
            "PARTITION par#{date}\n" +
            "group by course_name\n" +
            "order by order_total_amount limit #{limit}")
    List<TradeSubjectOrderAmount> selectSubjectAmount(@Param("date") Integer date, @Param("limit") Integer limit);

}
